using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using DTO;

using System.Data;

namespace Business
{
    public class PhieuThueService
    {




		//////////////////////////////////////////////////////////

 		                                                         

		//            Enter code your here                      //


        static public PhieuThueDTO LayPhieuThueHienTaiCuaPhong(int MaPhong)
        {
            PhieuThueRepository Repo = new PhieuThueRepository();
            return Repo.LayPhieuThueHienTaiCuaPhong(MaPhong);
        }                        

		//////////////////////////////////////////////////////////

       static public DataTable ConvertListPhieuThueDTOToDataTable( List<PhieuThueDTO> lst)
       {
               DataTable dt = new DataTable();
           dt.Columns.Add( "MaPhieuThue");
           dt.Columns.Add( "NgayBatDauThue");
           dt.Columns.Add( "MaPhong");
           dt.Columns.Add( "NgayKetThuc");
           dt.Columns.Add( "DonGia");
           for( int i = 0; i < lst.Count; i ++)
           {
               dt.Rows.Add(
                       lst[i].MaPhieuThue,      
                       lst[i].NgayBatDauThue,      
                       lst[i].MaPhong,      
                       lst[i].NgayKetThuc,      
                       lst[i].DonGia      
                   );
           }
               return dt;
       }
        static public int GetIdentity()
        {
            Data.PhieuThueRepository repo = new PhieuThueRepository();
            return repo.GetIdentity();
        }

        static public int Count()
        {
            return PhieuThueRepository.Count();
        }
        public static bool Them(PhieuThueDTO objDTO)
        {
                PhieuThueRepository repo = new PhieuThueRepository();
                return repo.Them(objDTO);
        }

        public static bool Xoa(int MaPhieuThue, bool XoaKhoaNgoai=false)
        {
              PhieuThueRepository Repo = new PhieuThueRepository();
              return Repo.Xoa(MaPhieuThue,XoaKhoaNgoai);
        }

        public static void CapNhat(PhieuThueDTO objDTO)
        {
            try
            {
                PhieuThueRepository Repo = new PhieuThueRepository();
                Repo.CapNhat(objDTO);
            }
            catch (System.Exception )
            {
            }
        }

        public static List<PhieuThueDTO> LayDanhSach()
        {
            List<PhieuThueDTO> lst = new List<PhieuThueDTO>();
            try
            {
                PhieuThueRepository obj = new PhieuThueRepository();
                lst = obj.LayDanhSach();
            }
            catch (System.Exception )
            {
            }
            return lst;
        }

        static public List<PhieuThueDTO> LayDanhSach(int Start, int Record)
        {
             Data.PhieuThueRepository repo = new PhieuThueRepository();
            return repo.LayDanhSach(Start, Record);
        }

        public static PhieuThueDTO LayTheoMa(int MaPhieuThue)
        {
            PhieuThueDTO objDTO = new PhieuThueDTO();
            try
            {
                PhieuThueRepository Repo = new PhieuThueRepository();
                objDTO = Repo.LayTheoMa(MaPhieuThue);
            }
            catch (System.Exception )
            {
            }
            return objDTO;
        }

//
//Khoa ngoai Phong
//
        static public List<PhieuThueDTO> LayDanhSachTheoMaPhong( int MaPhong)
        {
             Data.PhieuThueRepository repo = new PhieuThueRepository();
            return repo.LayDanhSachTheoMaPhong( MaPhong);
        }

        static public void XoaTheoMaPhong( int MaPhong, bool XoaKhoaNgoai=false)
        {
             Data.PhieuThueRepository repo = new PhieuThueRepository();
            repo.XoaTheoMaPhong( MaPhong,XoaKhoaNgoai);
        }

    }
}

